package com.hs.demo.task;
import com.hs.demo.entity.TbDetectionRl;
import com.hs.demo.mapper.TbDetectionRlMapper;
import com.hs.demo.mina.MinaServer;
import com.hs.demo.vo.TbDetectionRlVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Configuration  //标记配置类
@EnableScheduling   //开启定时任务
public class MyScheduleTask {
    @Autowired
    MinaServer minaServer;
    @Autowired
    private TbDetectionRlMapper tbDetectionRlMapper;
    //添加定时任务
    @Scheduled(cron = "0/5 * * * * ?")
    private void myTasks() throws IOException {
        if(!MinaServer.isRun){
            System.out.println("执行定时任务启动minaServer");
            minaServer.start();
        }
    }
//    @Scheduled(cron = "0/5 * * * * ?")
//    private void detectionRl(){
//        TbDetectionRl tbDetectionRl = new TbDetectionRl();
//        tbDetectionRl.setState(1);
//        List<TbDetectionRlVO> tbDetectionRls = tbDetectionRlMapper.selectTbDetectionRlListCondition(tbDetectionRl);
//
//        System.out.println("要更新" + tbDetectionRls.size() + "条");
//        int i = tbDetectionRlMapper.updateBatch(tbDetectionRls);
//        System.out.println("更新" + i + "条");
//    }
}
